package day050626;

import java.util.Arrays;
import java.util.Comparator;

public class Test12 {
    public static void main(String[] args) {
        Integer[] a={1,2,3,4,5};
        //Arrays.sort(引用类型数组数组名,   排序规则);
        Arrays.sort(a, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                return  o2-o1;
            }
        });

        System.out.println(Arrays.toString(a));


        String[] b={"hello" , "java" ,"world", "tom"};
        Arrays.sort(b, new Comparator<String>() {
            public int compare(String o1, String o2) {
                return o2.length()- o1.length();
            }
        });
        System.out.println(Arrays.toString(b));


        Double[] d={6.51,  6.81,    8.4,  7.9};
        Arrays.sort(d, new Comparator<Double>() {
            public int compare(Double o1, Double o2) {
                return  (int)(o2*100 - o1*100);
            }
        });
        System.out.println(Arrays.toString(d));


    }
}
